package com.example.xm.ui.home.fragments.activity_article;

import android.os.Bundle;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.xm.R;
import com.example.xm.adapter.HomeAdapter.Article_DaShiJianAdapter;
import com.example.xm.base.BaseActivity;
import com.example.xm.bean.HomeBean.HomeArticleChuanTongBean;
import com.example.xm.bean.HomeBean.HomeArticleDaShiJianBean;
import com.example.xm.bean.HomeBean.HomeArticleRenShiBean;
import com.example.xm.bean.HomeBean.HomeArticleYanJinBean;
import com.example.xm.interfaces.home.IArticle;
import com.example.xm.presenter.home.ArticlePresenter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class Article_DaShiJianActivity extends BaseActivity<IArticle.ArticlePresenter> implements IArticle.ArticleView {

    @BindView(R.id.rlv_dashijian)
    RecyclerView rlvDashijian;
    private ArrayList<HomeArticleDaShiJianBean.DataBean> list;
    private Article_DaShiJianAdapter article_daShiJianAdapter;

    @Override
    protected IArticle.ArticlePresenter initPresenter() {
        return new ArticlePresenter();
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_article__da_shi_jian;
    }

    @Override
    protected void initView() {
        list = new ArrayList<>();
        rlvDashijian.setLayoutManager(new LinearLayoutManager(this));
        article_daShiJianAdapter = new Article_DaShiJianAdapter(this, list);
        rlvDashijian.setAdapter(article_daShiJianAdapter);
    }

    @Override
    protected void initData() {
        mPresenter.getDaShiJian();
    }

    @Override
    protected void initListener() {

    }

    @Override
    public void getRenShiResult(HomeArticleRenShiBean result) {

    }

    @Override
    public void getChuanTongResult(HomeArticleChuanTongBean result) {

    }

    @Override
    public void getYanJinResult(HomeArticleYanJinBean result) {

    }

    @Override
    public void getDaShiJianResult(HomeArticleDaShiJianBean result) {
        if (result.getStatus().getStatusCode() == 100) {
            List<HomeArticleDaShiJianBean.DataBean> data = result.getData();
            list.addAll(data);
            article_daShiJianAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void showTips(String tips) {

    }

    @Override
    public void showLoading(int visble) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}